#include "SDL2/SDL.h"
#include <iostream>

//定义屏幕尺寸常量
const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;

using namespace std;

int main( int argc, char* argv[] )
{
    (void)argc;
    (void)argv;

    //将要渲染的窗口
    SDL_Window* window = NULL;

    //窗口含有的surface
    SDL_Surface* screenSurface = NULL;

    //初始化SDL
    if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
       cout << SDL_GetError() << endl;
       return 1;
    }

    //创建 window
    window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, 
        SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN );
    if( window == NULL )
    {
        cout << SDL_GetError() << endl;
        return 1;
    }


    //获取 window surface
    screenSurface = SDL_GetWindowSurface( window );

    //用白色填充surface
    SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );

    //更新surface
    SDL_UpdateWindowSurface( window );

    //延迟两秒
    SDL_Delay( 2000 );



    //销毁 window
    SDL_DestroyWindow( window );

    //退出 SDL subsystems
    SDL_Quit();

    return 0;
}